<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace OSS\Model;

class LoggingConfig implements XmlConfig
{
    private $targetBucket = "";
    private $targetPrefix = "";
    public function __construct($targetBucket = NULL, $targetPrefix = NULL)
    {
        $this->targetBucket = $targetBucket;
        $this->targetPrefix = $targetPrefix;
    }
    public function parseFromXml($strXml)
    {
        $xml = simplexml_load_string($strXml);
        if(!isset($xml->LoggingEnabled)) {
            return NULL;
        }
        foreach ($xml->LoggingEnabled as $status) {
            foreach ($status as $key => $value) {
                if($key === "TargetBucket") {
                    $this->targetBucket = strval($value);
                } elseif($key === "TargetPrefix") {
                    $this->targetPrefix = strval($value);
                }
            }
        }
    }
    public function serializeToXml()
    {
        $xml = new \SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\"?><BucketLoggingStatus></BucketLoggingStatus>");
        if(isset($this->targetBucket) && isset($this->targetPrefix)) {
            $loggingEnabled = $xml->addChild("LoggingEnabled");
            $loggingEnabled->addChild("TargetBucket", $this->targetBucket);
            $loggingEnabled->addChild("TargetPrefix", $this->targetPrefix);
        }
        return $xml->asXML();
    }
    public function __toString()
    {
        return $this->serializeToXml();
    }
    public function getTargetBucket()
    {
        return $this->targetBucket;
    }
    public function getTargetPrefix()
    {
        return $this->targetPrefix;
    }
}

?>